#ifndef LINKTRACK_DATA_H
#define LINKTRACK_DATA_H

#include "protocols.h"
#include <vector>
#include <iostream>

typedef struct
{
  linktrack_role_e role;
  uint8_t id;
  uint16_t data_length;
  //可根据自身情况设置单节点单次最大数传长度，上限参考
  // LinkTrack Datasheet
  std::vector<uint8_t> data;
} dataNode;

//Add for print
class AnchorFrame0_Msg
{
public:
    AnchorFrame0_Msg(){};
    ~AnchorFrame0_Msg(){};
    void show()
    {
        std::cout<< "AnchorFrame0 info:" << std::endl;
        std::cout<< "role:" << role << " ";
        printf("id:%d local_time:%d system_time:%d voltage:%f\n",
               id, local_time, system_time, voltage);
        for(int i=0; i<nodes.size();i++)
        {
            auto node = nodes.at(i);
            printf("[node%d]",node.id);
            std::cout << "role:" << node.role;
            printf("pos: (%f,%f,%f) ",node.pos_3d[0],node.pos_3d[1],node.pos_3d[2]);
            printf("dis: (%f,%f,%f,%f,%f,%f,%f)",node.dis_arr[0],node.dis_arr[1],node.dis_arr[2],
                                    node.dis_arr[3],node.dis_arr[4],node.dis_arr[5],node.dis_arr[6]);
        }
        std::cout << std::endl;
    };

 public:
    linktrack_role_e role;
    uint8_t id;
    uint32_t local_time;
    uint32_t system_time;
    float voltage;
    std::vector<nlt_anchorframe0_node_t> nodes;
};

class TagFrame0_Msg
{
public:
    TagFrame0_Msg(){};
    ~TagFrame0_Msg(){};
    void show()
    {
        std::cout<< "TagFrame0 info:" << std::endl;
        std::cout<< "role:" << role << " ";
        printf("id:%d local_time:%d system_time:%d voltage:%f\n",
               id, local_time, system_time, voltage);
        printf("pos: (%f,%f,%f) ",pos_3d[0],pos_3d[1],pos_3d[2]);
        printf("eop: (%f,%f,%f) ",eop_3d[0],eop_3d[1],eop_3d[2]);
        printf("vel: (%f,%f,%f) ",vel_3d[0],vel_3d[1],vel_3d[2]);
        printf("dis: (%f,%f,%f,%f,%f,%f,%f,%f)",dis_arr[0],dis_arr[1],dis_arr[2],
                                dis_arr[3],dis_arr[4],dis_arr[5],dis_arr[6],dis_arr[7]);
        printf("angle: (%f,%f,%f) ",angle_3d[0],angle_3d[1],angle_3d[2]);
        printf("quaternion: (%f,%f,%f,%f) ",quaternion[0],quaternion[1],quaternion[2],quaternion[3]);
        printf("imu_gyro: (%f,%f,%f) ",imu_gyro_3d[0],imu_gyro_3d[1],imu_gyro_3d[2]);
        printf("imu_acc: (%f,%f,%f) ",imu_acc_3d[0],imu_acc_3d[1],imu_acc_3d[2]);

        std::cout << std::endl;
    };

 public:
    linktrack_role_e role;
    uint8_t id;
    uint32_t local_time;
    uint32_t system_time;
    float voltage;
    float pos_3d[3];
    float eop_3d[3];
    float vel_3d[3];
    float dis_arr[8];
    float angle_3d[3];
    float quaternion[4];
    float imu_gyro_3d[3];
    float imu_acc_3d[3];
};

class NodeFrame0_Msg
{
public:
    NodeFrame0_Msg(){};
    ~NodeFrame0_Msg(){};
    void show()
    {
        std::cout<< "NodeFrame0 info:" << std::endl;
        std::cout<< "role:" << role << " ";
        std::cout<< "id:" << id <<" ";
        for(int i=0; i<nodes.size();i++)
        {
            auto node = nodes.at(i);
            printf("[node%d]",node.id);
            std::cout << "role:" << node.role;
            std::cout << "data:";
            for(uint16_t i=0; i< node.data_length;i++)
            {
                std::cout << " " << node.data[i];
            }
            std::cout << std::endl;
        }
    };

public:
   uint8_t role;
   uint8_t id;
   std::vector<dataNode> nodes;
};

class NodeFrame1_Msg
{
public:
    NodeFrame1_Msg(){};
    ~NodeFrame1_Msg(){};
    void show()
    {
        std::cout<< "NodeFrame1 info:" << std::endl;
        std::cout<< "role:" << role << " ";
        printf("id:%d local_time:%d system_time:%d voltage:%f\n",
               id, local_time, system_time, voltage);
        for(int i=0; i<nodes.size();i++)
        {
            auto node = nodes.at(i);
            printf("[node%d]",node.id);
            std::cout << "role:" << node.role;
            printf("pos: (%f,%f,%f) ",node.pos_3d[0],node.pos_3d[1],node.pos_3d[2]);
            std::cout << std::endl;
        }
    };

public:
    linktrack_role_e role;
    uint8_t id;
    uint32_t local_time;
    uint32_t system_time;
    float voltage;
    std::vector<nlt_nodeframe1_node_t> nodes;
};

class NodeFrame2_Msg
{
public:
    NodeFrame2_Msg(){};
    ~NodeFrame2_Msg(){};
    void show()
    {
        std::cout<< "NodeFrame2 info:" << std::endl;
        std::cout<< "role:" << role << " ";
        printf("id:%d local_time:%d system_time:%d voltage:%f\n",
               id, local_time, system_time, voltage);
        printf("pos: (%f,%f,%f) ",pos_3d[0],pos_3d[1],pos_3d[2]);
        printf("eop: (%f,%f,%f) ",eop_3d[0],eop_3d[1],eop_3d[2]);
        printf("vel: (%f,%f,%f) ",vel_3d[0],vel_3d[1],vel_3d[2]);
        printf("dis: (%f,%f,%f,%f,%f,%f,%f,%f)",dis_arr[0],dis_arr[1],dis_arr[2],
                                dis_arr[3],dis_arr[4],dis_arr[5],dis_arr[6],dis_arr[7]);
        printf("angle: (%f,%f,%f) ",angle_3d[0],angle_3d[1],angle_3d[2]);
        printf("quaternion: (%f,%f,%f,%f) ",quaternion[0],quaternion[1],quaternion[2],quaternion[3]);
        printf("imu_gyro: (%f,%f,%f) ",imu_gyro_3d[0],imu_gyro_3d[1],imu_gyro_3d[2]);
        printf("imu_acc: (%f,%f,%f) ",imu_acc_3d[0],imu_acc_3d[1],imu_acc_3d[2]);
        std::cout << std::endl;

        for(int i=0; i<nodes.size();i++)
        {
            auto node = nodes.at(i);
            printf("[node%d]",node.id);
            std::cout << "role:" << node.role <<" ";
            std::cout << "dis:" << node.dis << " ";
            std::cout << "fp_rssi:" << node.fp_rssi << " ";
            std::cout << "rx_rssi:" << node.rx_rssi << " ";
            std::cout << std::endl;
        }
    };

public:
    linktrack_role_e role;
    uint8_t id;
    uint32_t local_time;
    uint32_t system_time;
    float voltage;
    float pos_3d[3];
    float eop_3d[3];
    float vel_3d[3];
    float dis_arr[8];
    float angle_3d[3];
    float quaternion[4];
    float imu_gyro_3d[3];
    float imu_acc_3d[3];
    std::vector<nlt_nodeframe2_node_t> nodes;
};

class NodeFrame3_Msg
{
public:
    NodeFrame3_Msg(){};
    ~NodeFrame3_Msg(){};
    void show()
    {
        std::cout<< "NodeFrame2 info:" << std::endl;
        std::cout<< "role:" << role << " ";
        printf("id:%d local_time:%d system_time:%d voltage:%f\n",
               id, local_time, system_time, voltage);
        std::cout << std::endl;

        for(int i=0; i<nodes.size();i++)
        {
            auto node = nodes.at(i);
            printf("[node%d]",node.id);
            std::cout << "role:" << node.role <<" ";
            std::cout << "dis:" << node.dis << " ";
            std::cout << "fp_rssi:" << node.fp_rssi << " ";
            std::cout << "rx_rssi:" << node.rx_rssi << " ";
            std::cout << std::endl;
        }
    };

public:
    linktrack_role_e role;
    uint8_t id;
    uint32_t local_time;
    uint32_t system_time;
    float voltage;
    std::vector<nlt_nodeframe3_node_t> nodes;
};

class NodeFrame5_Msg
{
public:
    NodeFrame5_Msg(){};
    ~NodeFrame5_Msg(){};
    void show()
    {
        std::cout<< "NodeFrame2 info:" << std::endl;
        std::cout<< "role:" << role << " ";
        printf("id:%d local_time:%d system_time:%d voltage:%f\n",
               id, local_time, system_time, voltage);
        std::cout << std::endl;

        for(int i=0; i<nodes.size();i++)
        {
            auto node = nodes.at(i);
            printf("[node%d]",node.id);
            std::cout << "role:" << node.role <<" ";
            std::cout << "dis:" << node.dis << " ";
            std::cout << "fp_rssi:" << node.fp_rssi << " ";
            std::cout << "rx_rssi:" << node.rx_rssi << " ";
            std::cout << std::endl;
        }
    };

public:
    linktrack_role_e role;
    uint8_t id;
    uint32_t local_time;
    uint32_t system_time;
    float voltage;
    std::vector<nlt_nodeframe5_node_t> nodes;
};

class NodeFrame6_Msg
{
public:
    NodeFrame6_Msg(){};
    ~NodeFrame6_Msg(){};
    void show()
    {
        std::cout<< "NodeFrame0 info:" << std::endl;
        std::cout<< "role:" << role << " ";
        std::cout<< "id:" << id <<" ";
        for(int i=0; i<nodes.size();i++)
        {
            auto node = nodes.at(i);
            printf("[node%d]",node.id);
            std::cout << "role:" << node.role;
            std::cout << "data:";
            for(uint16_t i=0; i< node.data_length;i++)
            {
                std::cout << " " << node.data[i];
            }
            std::cout << std::endl;
        }
    };

public:
    uint8_t role;
    uint8_t id;
    std::vector<dataNode> nodes;
};
#endif // LINKTRACK_PROTOCOLS_DATA_H
